# ICX Switch Configuration Script with Posh-SSH # This script is designed to extract IP Addresses from switches.txt, SSH into the switch # with the provided credentials (brocade, brocade), and backup the configuration of the switches # to a TFTP Server. The output will be saved in the root TFTP directory and the file will be named # for the switch IP Address and then exit the session. # # Enter user credentials into the script $User = "brocade" $PWord = ConvertTo-SecureString -String "brocade" -AsPlainText -Force $Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord # Read hosts into the variable to perform on multiple hosts foreach($switchip in Get-Content .\switches.txt) { #Open the SSH session New-SSHSession -ComputerName $switchip -Credential ($Credential) -AcceptKey -Force -Verbose $SSHStream = New-SSHShellStream -Index 0 #Break to establish session sleep 10 # Write commands to the switch $SSHStream.WriteLine("copy running-config tftp 10.10.10.100 " +$switchip ".txt") sleep 2 # End SSH session Remove-SSHSession -Index 0 }